<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Family extends Model
{
    protected $table = 'love_family';

    const UPDATED_AT = null;

    public function users()
    {
        return $this->hasMany(\App\Models\Family\User::Class);
    }

    public function userDetails()
    {
        return $this->belongsToMany(User::Class, 'love_family_users')
            ->select(['love_users.id','love_users.username','love_users.mobile','love_family_users.is_householder'])
            ->orderBy('love_family_users.is_householder', 'desc');
    }

    public function user()
    {
        return $this->belongsToMany(User::Class, 'love_family_users');
    }

    public function householder()
    {
        return $this->belongsTo(User::Class, 'householder_id');
    }

}
